<template>
	<view>
		<u-navbar :is-back="true" :border-bottom="false" title="选择项目" title-color="white"
			:background="{backgroundColor: '#00a8ff'}">
		</u-navbar>
		<view class="" v-for="(item,index) in ordersList">
			<view class="u-padding-26 bg">
				<view class="">
					<image :src="user.avatar" mode="" style="width: 50rpx;height: 50rpx;border-radius: 50%;">
					</image>
					<text style="position: relative;top:-10rpx">{{user.user_name}}</text>
					<span style="color: #b4b3b4;float: right;position: relative;top:10rpx" class="u-font-10 u-m-r-16"
						@click="overOrder(item.id)">查看档案
						<u-icon name="arrow-right"></u-icon>
					</span>
				</view>
				<view class="u-flex u-margin-top-10 u-margin-bottom-10">
					<view class="u-flex-1">
						<image :src="oss+item.items[0].image_id" mode=""
							style="width: 150rpx;border-radius: 10rpx;height: 150rpx;"></image>
					</view>
					<view class="u-flex-3">
						<p class="u-col-top">{{item.items[0].name}}</p>
						<br>
						<p>￥{{item.order_total}}</p>
					</view>
				</view>
				<view class="">
					<p style="color: #6c6c6c;display: inline-block;" class="u-font-10">
						<u-icon name="map" class="u-m-r-10"></u-icon>上海市第一人民医院
					</p>
					<p style="color: #6c6c6c;display: inline-block;float: right;margin-top: 5rpx;" class="u-font-10">
						<u-icon name="clock" class="u-m-r-10"></u-icon>
						{{$u.timeFormat(timestamp, 'yyyy年mm月dd日')}}
					</p>
				</view>
			</view>
			<view class="" style="height: 20rpx;background-color: #f3f4f5;">
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		onLoad(e) {
			console.log(e);
			this.user = e;
			this.getOrders(e.user_id);
		},
		data() {
			return {
				oss: 'http://zjmeifeng.oss-cn-beijing.aliyuncs.com/',
				user: [],
				ordersList: []
			}
		},
		methods: {
			// 查看档案
			overOrder(id) {
				// 传入订单id查看档案控制页面是否跳转
				console.log(id);
				this.$apiBasics.orderdetail({
					id: id
				}).then((res) => {
					console.log('request success', res);
					console.log(res.data.msg)
					if (res.data.msg == "档案还未上传") {
						uni.showToast({
							title: res.data.msg
						})
					} else {
						// 跳转到档案详情  // 传入订单id
						this.openinfo('/pages/tabBar/archivesCenter/particulars?id=' + id);
					}
				}).catch((err) => {
					console.log('request fail', err);
				})
			},
			// 根据用户id查询用户项目列表
			getOrders(user_id) {
				console.log(user_id);
				this.$apiBasics.orders({
					user_id: user_id
				}).then((res) => {
					console.log('request success', res);
					this.ordersList = res.data.data.items;
					console.log(this.ordersList)
	
				}).catch((err) => {
					console.log('request fail', err);
				})
			},
			openinfo(url) {
				uni.navigateTo({
					url: url,
				});
			},
		}
	}
</script>

<style scoped lang="scss">

</style>
